Skip to content

fix: start the close handshake for every close frame - #95

Open
nmbrone wants to merge 5 commits into
mainfrom
fix/close-handshake
Open

fix: start the close handshake for every close frame#95
nmbrone wants to merge 5 commits into
mainfrom
fix/close-handshake

Conversation

@nmbrone

@nmbrone nmbrone commented Sep 4, 2026

Copy link
Copy Markdown
Owner

Only a close frame received from the server, or returned as {:close, code, reason, state} from a callback, went through the close handshake. One sent with Minch.send_frame/2 or returned as {:reply, frame, state} was written straight to the socket: no :close_timeout was armed, further frames were still accepted, and the disconnect was reported as a transport error instead of the frame.

Every close frame now starts the handshake, whichever path it comes from. Frames that arrive while it is in flight are still delivered to handle_frame/2 rather than dropped, a ping is still answered, and the connection is torn down as soon as both sides have sent a close frame instead of waiting for the server to close the socket.

Frames sent during a handshake are rejected with the new {:error, :closing}.

Only a close frame received from the server, or returned as `{:close, code, reason, state}`
from a callback, went through the close handshake. One sent with `Minch.send_frame/2` or
returned as `{:reply, frame, state}` was written straight to the socket: no `:close_timeout`
was armed, further frames were still accepted, and the disconnect was reported as a transport
error instead of the frame.

Every close frame now starts the handshake, whichever path it comes from. Frames that arrive
while it is in flight are still delivered to `handle_frame/2` rather than dropped, a ping is
still answered, and the connection is torn down as soon as both sides have sent a close frame
instead of waiting for the server to close the socket.

Frames sent during a handshake are rejected with the new `{:error, :closing}`.
The third way an application can start the handshake, alongside `Minch.send_frame/2` and the `{:close, code, reason, state}` callback result.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant